<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
	    <?php $this->load->view('layout/Header'); ?>
	    <?php $this->load->view('layout/Modal'); ?>
		<title>DotA 2 Shop</title>
	</head>
	<body>

		<!-- Nav bar -->

		<?php $this->load->view('layout/Navbar'); ?>

		<!-- End Nav -->

		<div class="row" id="row1">
			<div class="col-md-1"></div>

			<div class="col-md-10" id="menubar">
				<?php $this->load->view('layout/Menubar', $hero); ?>
			</div>
		</div>
		
		<br/>

		<!-- Content -->
		<div class="row">
			<div class="col-md-1">
			</div>

			<div class="col-md-10">
				<!-- Sort -->
                <form action="<?php echo base_url('item/searched_hero') ?>" method="POST">
                  <input type="hidden" name="hero_found" value="<?php if(isset($hero_found)) echo $hero_found; ?>" />
				<div class="QuickSort">
					<div class="row" id="RowQuickSort">
						<div class="col-md-3" >
							Hero: <br/>
							<select name="cboHero" class="Sort form-control">
								<option value="All">All</option>
								<?php if(isset($hero)): ?>
                                	<?php foreach($hero as $he): ?>
                                		<?php if($he->HERO_NAME != ''): ?>
                                			<option value="<?php echo $he->HERO_NAME ?>" <?php
                                				if(isset($hero_found))  if($hero_found == $he->HERO_NAME) echo "selected=selected";

                                			 if(@$_POST['cboHero'] == $he->HERO_NAME) echo "selected=selected"; 
                                                                                              if(isset($hero_search))
                                                                                                    if($hero_search == $he->HERO_NAME) echo "selected=selected";
                                        
                                        ?> ><?php echo $he->HERO_NAME ?></option>
                                		<?php endif; ?>
                                	<?php endforeach; ?>
                                <?php endif; ?>
							</select>
						</div>

						<div class="col-md-3">
							Rarity: <br/>
							<select name="cboRarity" class="Sort form-control">
								<option value="All">All</option>
								<?php if(isset($rarity)): ?>
                                	<?php foreach($rarity as $ra): ?> 
                                		<?php if($ra->ITEM_RARITY != ''): ?>
                                			<option value="<?php echo $ra->ITEM_RARITY ?>" <?php if(@$_POST['cboRarity'] == $ra->ITEM_RARITY) echo "selected=selected"; 
                                                                                                else if(isset($rarity_search))
                                                                                                    if($rarity_search == $ra->ITEM_RARITY) echo "selected=selected";
                                        
                                        ?> ><?php echo $ra->ITEM_RARITY ?></option>
                                		<?php endif; ?>
                                	<?php endforeach; ?>
                                <?php endif; ?>
							</select>
						</div>
                        <div class="col-md-6"> 
                           Tìm theo tên item/set item: <br/>
                            <input type="text" class="Sort form-control" id="item_name" name="item_name" placeholder="Nhập tên Item/Set Item" style="text-align: center;" width="100%" />
                        </div>
                     
					</div>
                    <div class="row">
                    <div class="col-md-6 col-md-offset-6">
                    <button type='submit' name='btnsearch' value='Search' class="btn btn-info" >Search</button> </div> </div>
                    <br />
				</div>
                
                 </form>
				<!-- Pagination Top -->
				<div class="Pagination">
					<div class="row">
						<div class="ItemPerPage">
							
						</div>
						<div class="RowPagination">
							<?php echo $pagination;?>
						</div>
					</div>
				</div>
				<!-- Items -->
				<div class="Items">
					<div class="row" id="Items">
					<?php if(is_array($List_Items)): ?>
						<?php foreach($List_Items as $List_Item): ?>
							<form action='<?php echo base_url(); ?>cart/add_cart' method='post'>
			                    <div class='col-md-3 span7 text-center' id="item" >
				        		<a class="btn" href="<?php echo base_url(); ?>item/get_info_item_by_id/<?php print $List_Item->ITEM_ID ?>" >
				                    <?php $sample_data = $this->m_item->get_new_saleoff_chung();
					if($sample_data[0]->SAMPLE_VALUE != 1 || $List_Item->IS_SALE == 1) { ?>
				 <span class="div_sale1">
						<?php
												        if($List_Item->IS_SALE == 0)
												        {
												            $sample_data = $this->m_item->get_new_saleoff_chung();
												            $saleoff = $sample_data[0]->SAMPLE_VALUE;
												            echo ($saleoff - 1)*100 .'%' ;
												        }
												        else if($List_Item->IS_SALE == 1)
												        {
												            $saleoff1 = $this->m_item->get_new_saleoff_by_itemid($List_Item->ITEM_ID);
												            $saleoff = $saleoff1[0]->SOVALUE;
												            echo ($saleoff - 1)*100 .'%' ;

												        }

												         
						?>

				</span>   <?php } ?>
				                    <img class="productimage" src="<?php print $List_Item->ITEM_IMAGE; ?>">
				                    <p class="productinfo"><small><b><?php print $List_Item->ITEM_NAME; ?></b></small></p>
				                    <p class="productinfo"><b><small><?php if($List_Item->PRICE != '') echo $List_Item->PRICE; else echo $List_Item->PRICEVN; ?> VND</small></b></p>
			                    </a>
				                    <?php if($this->session->userdata('username') != ''): ?>
							        	<button type='submit' name='btnAction' value='addcart' class="btn btn-success" >Add to Cart</button>
							    	<?php else: ?>
							    		<button type='submit' name='btnAction' value='addcart' class="btn btn-success" disabled >Add to Cart</button>
							    	<?php endif; ?>
				                    <input type='hidden' name='productid' value='<?php print $List_Item->ITEM_ID; ?>' />

			                    </div>
		                    </form>
	                	<?php endforeach; ?>
	                <?php endif; ?>
					</div>
				</div>

				<!-- Pagination Bottom -->
				<div class="Pagination">
					<div class="row">
						<div class="RowPagination">
							<?php echo $pagination;?>
						</div>
					</div>
				</div>
			</div>
		</div>
		


		<!-- Footer -->
		<?php $this->load->view('layout/Footer'); ?>

	</body>
</html>